package org.ligson.user.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.atomic.AtomicInteger;

@RestController
@RequestMapping("/api/user")
@Slf4j
public class UserController {
    @Value("${app.time:1000}")
    private int time;
    static AtomicInteger count = new AtomicInteger(0);

    @GetMapping("/test")
    public String test() throws InterruptedException {
        Thread.sleep(time);
        log.info("count:{}", count.getAndIncrement());
        return "OK";
    }

    @GetMapping("/reset")
    public String reset() {
        count.set(0);
        return count.get() + "";
    }
}
